﻿@{
	Layout = null;
}

<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 <title>即时库存</title>
 <link rel="stylesheet" href="/layui/css/layui.min.css" />

 <style>
  .layui-table-total tr {
   background-color: #ffffff !important;
  }
 </style>

</head>
<body>
 <script type="text/html" id="selectPL">
  <select lay-search id="FStock" name="FStock">
	 <option value="" selected>全部</option>
			@foreach (var item in ViewBag.StockList)
			{
		<option value="@item.FNumber">@item.FName</option>
			}
  </select>
 </script>
 <div id="tableSearch"></div>
 <div class="layui-card">
  <div class="layui-card-body">
   <table class="layui-hide" id="table1" lay-filter="table1"></table>
  </div>
 </div>
 <script type="text/html" id="menu-toolbar">
  <fieldset class="layui-elem-field layui-field-title">
   <legend>即时库存</legend>
  </fieldset>
 </script>

 <script src="/layui/layui.min.js"></script>

 <script>
  layui.config({ base: '/layui_exts/' }).extend({
   dynamicCondition: 'dynamicCondition/dynamicCondition'
  }).use(['table', 'layer', 'form', 'dynamicCondition'], function () {
   let form = layui.form;
   let $ = layui.$;
   let layer = layui.layer;
   let table = layui.table;
   let dynamicCondition = layui.dynamicCondition;
   var dc = dynamicCondition.create({
	type: "complex"
	, fields: [
	 { field: 'FMaterialId__FNumber', title: '物料编码', edit: 'text', ops: 'like,start,end,equal,unequal,empty,notempty,in,notin' }
	 , { field: 'FMaterialName', title: '物料名称', edit: 'text', ops: 'like,start,end,notlike,equal,unequal,empty,notempty' }
	 , { field: 'FModel', title: '型号规格', edit: 'text', ops: 'like,start,end,equal,unequal,empty,notempty' }
	 , { field: 'FLot__FNumber', title: '批号', edit: 'text', ops: 'like,start,end,equal,unequal,empty,notempty' }
	 , { field: 'FStockId__FNumber', title: '仓库', edit: 'select', templet: '#selectPL' }
	 , { field: 'fBaseQty', title: '数量', edit: 'text', ops: 'between,greater_than,less_than' }
	]
	, conditionTextId: "#tableSearch"
	, requestDataType: "json"
	, popupBtnsWidth: 350
	, popupShowQueryBtn: true
	, unpopupBtnswidth: 350
	, unpopupShowAddBtn: true
	, nestedQuery: false
	, opsMap: {"equal":"等于","like":"包含","between":"范围"
	, "start": "左包含", "end":"右包含","notlike":"不包含","unequal":"不等于","empty":"为空","notempty":"不为空","greater_than":"大于","less_than":"小于","in":"IN","notin":"Not IN"}
	, opsList: ["like","start","end","notlike", "equal", "unequal", "empty", "notempty", "between","greater_than","less_than","in","notin"]
	, queryCallBack: function (requestData) {
	 table.reload('table1', {
   page: {
	curr: 1
   }
   , method: 'post'
   , where: dynamicCondition.getInstance().buildRequestData()
	 }, 'data');
	}
   });
   var resData = table.render({
	elem: '#table1'
	, id: 'table1'
	, url: '/Home/Index'
	, method: 'post'
	, where: dynamicCondition.getInstance().buildRequestData()
	, cellMinWidth: 80
	, skin: 'line'
	, limits: [10, 50, 100, 500, 2000]
	, title: '即时库存'
	, toolbar: '#menu-toolbar'
	, defaultToolbar: ['filter',{
	 title: '引出Excel',
	 layEvent: 'excel',
	 icon: 'layui-icon-export'
	}]
	, cols: [[
	 { type: 'checkbox' }
	 , { field: 'FOwnerId__FNumber', title: '货主编码', hide: true }
	 , { field: 'FKeeperId__FNumber', title: '保管者编码', hide: true }
	 , { field: 'FMaterialId__FNumber', title: '物料编码', width: 120 }
	 , { field: 'FMaterialName', title: '物料名称', width: 220 }
	 , { field: 'FModel', title: '规格型号', width: 180 }
	 , { field: 'FLot__FNumber', title: '批号', width: 160 }
	 , { field: 'FStockId__FNumber', title: '仓库编码', hide: true }
	 , { field: 'FStockName', title: '仓库名称', width: 120 }
	 , { field: 'FStockStatusId__FNumber', title: '库存状态编码', hide: true }
	 , { field: 'FStockStatusId__FName', title: '库存状态', width: 120 }
	 , { field: 'FStockUnitId__FNumber', title: '单位编码', hide: true }
	 , { field: 'FStockUnitId__FName', title: '单位', width: 120, totalRowText: '合计:' }
	 , { field: 'FBaseQty', title: '数量', width: 120, totalRow: true }
	]]
	, page: true
	, totalRow: true
   });

   table.on('toolbar(table1)', function (obj) {
	if (obj.event === 'excel') {
	 window.location.href = '/Home/Export';
	}
   });

  });

 </script>

</body>
</html>